#include <iostream>

using namespace std;

int help(int num)
{
    int i = 1;
    int cnt = 0, sum = 0;
    while (sum < num)
    {
        if (i <= num - sum)sum += i;
        else
        {
            while (i > num - sum)i /= 2;
            sum += i;
        }
        cnt++;
        i *= 2;
    }

    return cnt;
}


int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int tmp;
        cin >> tmp;
        cout << help(tmp) << endl;
    }
}